`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 2021/03/30 18:38:25
// Design Name: 
// Module Name: define
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////

/*--------------------Coprocessor 0--------------------*/
// CP0 Registers
//`define         CP0_ZeroReg          8'd00
//`define         CP0_Index           {5'd00, 3'd0}
//`define         CP0_Random          {5'd01, 3'd0}
//`define         CP0_EntryLo0        {5'd02, 3'd0}
//`define         CP0_EntryLo1        {5'd03, 3'd0}
//`define         CP0_Context         {5'd04, 3'd0}
//`define         CP0_PageMask        {5'd05, 3'd0}
//`define         CP0_Wired           {5'd06, 3'd0}
`define         CP0_BadVAddr        {5'd08, 3'd0}
`define         CP0_Count           {5'd09, 3'd0}
//`define         CP0_EntryHi         {5'd10, 3'd0}
`define         CP0_Compare         {5'd11, 3'd0}
`define         CP0_Status          {5'd12, 3'd0}
`define         CP0_Cause           {5'd13, 3'd0}
`define         CP0_EPC             {5'd14, 3'd0}
//`define         CP0_PrId            {5'd15, 3'd0}
//`define         CP0_EBase           {5'd15, 3'd1}
//`define         CP0_Config          {5'd16, 3'd0}
//`define         CP0_Config1         {5'd16, 3'd1}
//`define         CP0_TagLo           {5'd28, 3'd0}
//`define         CP0_TagHi           {5'd29, 3'd0}
//`define         CP0_ErrorEPC        {5'd30, 3'd0}

// Fields of Status Register
`define         CU3                 31
`define         CU2                 30
`define         CU1                 29
`define         CU0                 28
`define         BEV                 22
`define         IM                  15: 8
`define         UM                   4
`define         ERL                  2
`define         EXL                  1
`define         IE                   0

// Fields of Cause Register
`define         BD                  31
`define         CE                  29:28
`define         IV                  23
`define         IPH                 15:10
`define         IPS                  9: 8
`define         IP                  15: 8
`define         ExcCode              6: 2

// Index of exception vector
`define         Exc_NMI             0
`define         Exc_Intr            1
`define         Exc_I_AdE           2
`define         Exc_I_TLBR          3
`define         Exc_I_TLBI          4
`define         Exc_I_BusE          5
`define         Exc_CpU             6
`define         Exc_CpUN            8: 7
`define         Exc_RI              9
`define         Exc_Ov              10
`define         Exc_Trap            11
`define         Exc_SysC            12
`define         Exc_Bp              13
`define         Exc_D_AdE           14
`define         Exc_D_TLBR          15
`define         Exc_D_TLBI          16
`define         Exc_D_TLBM          17
`define         Exc_D_BusE          18
`define         Exc_ERET            19
`define         Exc_Wait            20  //Not really an exception

// Exception Types
`define         ExcT_NoExc          `ExcT_W'h00
`define         ExcT_Intr           `ExcT_W'h01
`define         ExcT_CpU            `ExcT_W'h02
`define         ExcT_RI             `ExcT_W'h03
`define         ExcT_Ov             `ExcT_W'h04
`define         ExcT_Trap           `ExcT_W'h05
`define         ExcT_SysC           `ExcT_W'h06
`define         ExcT_Bp             `ExcT_W'h07
`define         ExcT_AdE            `ExcT_W'h08
`define         ExcT_TLBR           `ExcT_W'h09
`define         ExcT_TLBI           `ExcT_W'h0A
`define         ExcT_TLBM           `ExcT_W'h0B
`define         ExcT_IBE            `ExcT_W'h0C
`define         ExcT_DBE            `ExcT_W'h0D
`define         ExcT_ERET           `ExcT_W'h0E

// Cause.ExcCode
`define         ExcC_Intr           5'h00
`define         ExcC_Mod            5'h01
`define         ExcC_TLBL           5'h02
`define         ExcC_TLBS           5'h03
`define         ExcC_AdEL           5'h04
`define         ExcC_AdES           5'h05
`define         ExcC_IBE            5'h06
`define         ExcC_DBE            5'h07
`define         ExcC_SysC           5'h08
`define         ExcC_Bp             5'h09
`define         ExcC_RI             5'h0A
`define         ExcC_CpU            5'h0B
`define         ExcC_Ov             5'h0C
`define         ExcC_Tr             5'h0D